Total Complexity | 3 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | const { Guard } = require('./guard'); |
||
6 | class JgfNode { |
||
7 | |||
8 | /** |
||
9 | * Constructor |
||
10 | * @param {string} id Primary key for the node, that is unique for the object type. |
||
11 | * @param {string} label A text display for the node. |
||
12 | * @param {object|null} metadata Metadata about the node. |
||
13 | */ |
||
14 | constructor(id, label, metadata = null) { |
||
15 | this.id = id; |
||
16 | this.label = label; |
||
17 | this.metadata = metadata; |
||
18 | } |
||
19 | |||
20 | set metadata(metadata) { |
||
21 | Guard.assertValidMetadataOrNull(metadata); |
||
22 | this._metadata = metadata; |
||
23 | } |
||
24 | |||
25 | get metadata() { |
||
26 | return this._metadata; |
||
27 | } |
||
28 | } |
||
29 | |||
32 | }; |